package com.example.fmgidsprototype.data;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;

public class CategoryTable {
	
public static final String TABLE_NAME = "Category";
	
	public static class CategoryColumns implements BaseColumns{
		public static final String NAME = "name";
		public static final String DESCRIPTION = "description";
		public static final String ICON_NAME = "icon_name";
	}
	
	public static void onCreate(SQLiteDatabase db){
		StringBuilder sb = new StringBuilder();
		sb.append("create table if not exists " + CategoryTable.TABLE_NAME + " (");
		sb.append(BaseColumns._ID + " integer primary key, ");
		sb.append(CategoryColumns.NAME + " text unique not null, ");
		sb.append(CategoryColumns.DESCRIPTION + " text, ");
		sb.append(CategoryColumns.ICON_NAME + " text");
		sb.append(")");
		db.execSQL(sb.toString());
	}
	
	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		db.execSQL("drop table if exists " + CategoryTable.TABLE_NAME);
		onCreate(db);
	}
	
}
